package jdbc;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * 用于演示 DML 中delete 删除
 */
public class JdbcDemo04 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection  = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/tedu",
                "root", "root"
        );
       Statement statement =  connection.createStatement();
       String sql ="delete from userinfo where id =2";
       int num =  statement.executeUpdate(sql);
       System.out.println(num>0?"删除成功":"删除失败");
       connection.close();
    }
}
